package com.wl.mr.sortmub;

import com.wl.mr.sort.SortMapper;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class SortNumDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf, "SortNumDriver");

        job.setJarByClass(SortNumDriver.class);

        job.setMapperClass(SortNumMapper.class);
        job.setReducerClass(SortNumReducer.class);

        job.setMapOutputKeyClass(LongWritable.class);
        job.setMapOutputValueClass(NullWritable.class);

        job.setOutputKeyClass(LongWritable.class);
        job.setOutputValueClass(LongWritable.class);

        FileInputFormat.setInputPaths(job,"D:\\mystudentData\\input");
        FileOutputFormat.setOutputPath(job,new Path("D:\\mystudentData\\output"));

        boolean flag = job.waitForCompletion(true);

        System.exit(flag ? 0:1);
    }
}
